SPB Git

Repository Public

page.tsx 988 B 21 lines tsx

1import type { Metadata } from "next";2import { notFound } from "next/navigation";3import { ApiError } from "@/lib/http";4import { env } from "@/lib/env";5import { currentUser } from "@/lib/auth";6import { getSheetDetail } from "@/server/sheets";7import { Editor } from "@/components/editor/Editor";89export const dynamic = "force-dynamic";10export const metadata: Metadata = { title: "Éditeur" };1112export default async function Page({ params }: { params: Promise<{ id: string }> }) {13  const { id } = await params;14  // The layout redirects signed-out visitors; this page must not load a draft for anyone else either.15  const user = await currentUser();16  if (!user || user.method === "recovery_code" || !/^[0-9a-f-]{36}$/.test(id)) notFound();17  const detail = await getSheetDetail(id).catch((e: unknown) => { if (e instanceof ApiError && e.status === 404) return null; throw e; });18  if (!detail) notFound();19  return <Editor initial={detail} aiConfigured={!!env.anthropicApiKey} />;20}21
Files main
Menu

Theme